package inet.app.tuvi.util;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;

public class BitmapUtil {
	/**
	 * Rotate bitmap
	 * 
	 * @param source
	 * @param angle
	 * @return
	 */
	public static Bitmap rotateBitmap(Context context, Bitmap source,
			float angle) {
		Matrix matrix = new Matrix();
		matrix.postRotate(angle);
		return Bitmap.createBitmap(source, 0, 0, source.getWidth(),
				source.getHeight(), matrix, true);
	}

	/**
	 * Rotate bitmap from resource
	 * 
	 * @param context
	 * @param resId
	 * @param angle
	 * @return
	 */
	public static Bitmap rotateBitmap(Context context, int resId, float angle) {
		Bitmap source = BitmapFactory.decodeResource(context.getResources(),
				resId);
		return rotateBitmap(context, source, angle);
	}

}
